package CommonPages;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;

/**
 * Created by forgedone on 09.02.14.
 */
public class CommonPage {
    WebDriver driver;
    // getting WebDriver
    public CommonPage() {
        this.driver = WebDriverHolder.getWebDriver();
    }

    //liks to pages
    String mainPageAdress =  "http://vk.com/";
    String searchPageAdress = "http://vk.com/search";

    //links. left bar
    @FindBy(id="myprofile_wrap")
    WebElement myPageLink;
    @FindBy(id="l_fr")
    WebElement friendsLink;
    @FindBy(id="l_ph")
    WebElement photosLink;
    @FindBy(id="l_vid")
    WebElement videosLink;
    @FindBy(xpath = ".//*[@id='side_bar']/ol/li[5]")
    WebElement audiosLink;
    @FindBy(id="l_msg")
    WebElement messagesLink;
    @FindBy(id="l_gr")
    WebElement groupsLink;
    @FindBy(id="l_nws")
    WebElement newsLink;
    @FindBy(xpath = "//*[@id='side_bar']//li[11]")
    WebElement favesLink;
    @FindBy(id="l_set")
    WebElement settingsLink;
    @FindBy(id="l_ap")
    WebElement appsLink;
    @FindBy(xpath = "//*[@id='side_bar']/ol/li[14]")
    WebElement docsLink;

    //links. top
    /*
    commented cose it disappears sometimes. don`t know why
    @FindBy(id="head_people")
    WebElement searchPeopleLink;

    don`t know when or how get elements included
    @FindBy(id="head_music")
    WebElement topMusicLink;
    */
    @FindBy(id="head_communities")
    WebElement searchCommunitiesLink;
    @FindBy(id="head_games")
    WebElement searchAppLink;
    @FindBy(id="head_play_btn")
    WebElement playPauseMusic;
    @FindBy(id="top_support_link")
    WebElement supportLink;
    @FindBy(id="logout_link")
    WebElement logoutLink;


    //methods for links
    private void getMainPage(){
        driver.get(mainPageAdress);
    }
    private  void getSearchPage(){
        driver.get(searchPageAdress);
    }
    private void gotoMyPage(){
        myPageLink.click();
    }
    private void gotoFriendsPage(){
        friendsLink.click();
    }
    private void gotoPhotosPage(){
        photosLink.click();
    }
    private void gotoVideosPage(){
        videosLink.click();
    }
    private void gotoAudiosPage(){
        audiosLink.click();
    }
    private void gotoMessagesPage(){
        messagesLink.click();
    }
    private void gotoGroupsPage(){
        groupsLink.click();
    }
    private void gotoNewsPage(){
        newsLink.click();
    }
    private void gotoFavesPage(){
        favesLink.click();
    }
    private void gotoSettingsPage(){
        settingsLink.click();
    }
    private void gotoAppsPage(){
        appsLink.click();
    }
    private void gotoDocsPage(){
        docsLink.click();
    }
    //upper part
    private void gotoSearchCommunitiesPage(){
        searchCommunitiesLink.click();
    }
    private void gotoSearchAppsPage(){
        searchAppLink.click();
    }
    private void playPauseMusic(){
        playPauseMusic.click();
    }
    private void gotoSupportPage(){
        supportLink.click();
    }
    private void logOut(){
        logoutLink.click();
    }

}
